<template>
	<view class="count p-20">
		<view class="top b-f b-r-20 p-20 f f-a-c f-j-b f-w-w">
			<view @click="bigSmall" class="item f f-a-c f-d-c">
				<image src="/static/Store/1.png" class="image" mode=""></image>
				<view class="scan">
					扫码归还/活动核销
				</view>
			</view>
			<view @click="OnLoan" class="item f f-a-c  f-d-c">
				<image src="/static/Store/2.png" class="image" mode=""></image>
				<view class="scan">
					被借阅书籍
				</view>
			</view>
			<view @click="jilu" class="item f f-a-c  f-d-c">
				<image src="/static/Store/3.png" class="image" mode=""></image>
				<view class="scan">
					阅读通关记录
				</view>
			</view>
			<view @click="BookCard" class="item f f-a-c  f-d-c">
				<image src="/static/Store/4.png" class="image" mode=""></image>
				<view class="scan">
					读书会销卡
				</view>
			</view>
			<view @click="BookMen" class="item f f-a-c  f-d-c">
				<image src="/static/Store/5.png" class="image" mode=""></image>
				<view class="scan">
					门店数据统计
				</view>
			</view>
			<view @click="booksMen" class="item f f-a-c  f-d-c">
				<image src="/static/Store/6.png" class="image" mode=""></image>
				<view class="scan">
					门店书籍管理
				</view>
			</view>
			<view @click="codeUp" class="item f f-a-c  f-d-c">
				<image src="/static/Store/7.png" class="image" mode=""></image>
				<view class="scan">
					扫码录入书籍
				</view>
			</view>
			<view @click="codeJies" class="item f f-a-c  f-d-c">
				<image src="/static/Store/8.png" class="image" mode=""></image>
				<view class="scan">
					扫码借阅
				</view>
			</view>
		</view>
		<u-modal v-model="show" :show-cancel-button="true" @confirm="confirmFn" :content="content"></u-modal>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				content: '是否确认核销',
				show: false,
				code: ''
			}
		},
		methods: {
			// 扫码借阅
			codeJies() {
				uni.navigateTo({
					url: '/pages/index/BorrowNow'
				})
			},
			// 门店书记管理
			booksMen() {
				uni.navigateTo({
					url: '/pageC/StoreBook'
				})
			},
			// /门店数据统计
			BookMen() {
				uni.navigateTo({
					url: '/pageB/Statistics'
				})
			},
			BookCard() {
				uni.navigateTo({
					url: '/pageB/CancelTheCard'
				})
			},
			// 通关记录
			jilu() {
				uni.navigateTo({
					url: '/pageB/ClearanceRecord'
				})
			},
			// 跳转到被借阅书籍
			OnLoan() {
				uni.navigateTo({
					url: '/pageB/BooksOnLoan'
				})
			},
			// 点击扫码录入书籍
			codeUp() {
				uni.navigateTo({
					url: '/pageC/Append'

				})
			},
			// 点击确认
			async confirmFn() {
				let n = await this.$api.Offset({
					content: this.code
					// book_appearance_id: this.book_appearances[this.ind - 1].id
				})
				if (n.status) {
					this.$msg('核销成功')
				} else {
					this.$msg(n.message)
				}
			},
			// 扫码
			bigSmall() {
				uni.scanCode({
					success: async (res) => {
						console.log('条码类型：' + res.scanType);
						console.log('条码内容：' + res.result);
						uni.setStorageSync('code', res.result)
						this.code = res.result
						let m = await this.$api.Scan({
							content: res.result
						})

						if (m.status) {
							if (m.data.event == 'book_borrow') {
								// 借阅书

								let n = JSON.stringify(m.data.content)
								uni.navigateTo({
									url: `/pageB/BookInformation?code=${res.result}&obj=` + n
								})
							} else if (m.data.event == 'user_activity') {
								// 活动借阅书
								this.show = true

							}
						} else {
							this.$msg(m.message)
						}
					},

				});

			}
		},
	}
	// 书籍信息
</script>

<style lang="scss" scoped>
	.item {
		width: 19%;
		height: 200rpx;
		margin-right: 5%;
	}

	.item:nth-child(4n) {
		margin-right: 0%;
	}

	.scan {
		font-size: 26rpx;
		font-family: PingFang SC, PingFang SC-Bold;
		font-weight: 700;
		color: #333333;
		text-align: center;
	}

	.image {
		width: 76rpx;
		height: 76rpx;
		margin-bottom: 15rpx;
	}

	.top {
		width: 100%;
	}
</style>